#ifndef ABSTRACT_BOARD_H
#define ABSTRACT_BOARD_H

#include <http.h>
#include <web_socket.h>
#include <mqtt.h>
#include <udp.h>
#include <string>

void* g_create_board();
#define DECLARE_BOARD(BOARD_CLASS_NAME) \
void* g_create_board() { \
    return new BOARD_CLASS_NAME(); \
}

class Audio;
class Display;
class AbstractBoard {
private:
    AbstractBoard(const AbstractBoard&) = delete; // 禁用拷贝构造函数
    AbstractBoard& operator=(const AbstractBoard&) = delete; // 禁用赋值操作
    virtual std::string GetBoardJson() = 0;

protected:
    AbstractBoard();

public:
    static AbstractBoard& GetInstance() {
        static AbstractBoard* instance = nullptr;
        if (nullptr == instance) {
            instance = static_cast<AbstractBoard*>(g_create_board());
        }
        return *instance;
    }

    virtual ~AbstractBoard() = default;
    virtual Display* GetDisplay();
    virtual std::string GetJson();
    virtual bool GetBatteryLevel(int &level, bool& charging);

    virtual void StartNetwork() = 0;
    virtual Audio* GetAudio() = 0;
    virtual Http* CreateHttp() = 0;
    virtual WebSocket* CreateWebSocket() = 0;
    virtual Mqtt* CreateMqtt() = 0;
    virtual Udp* CreateUdp() = 0;
    virtual bool GetNetworkState(std::string& network_name, int& signal_quality, std::string& signal_quality_text) = 0;
    virtual const char* GetNetworkStateIcon() = 0;
    virtual void SetPowerSaveMode(bool enabled) = 0;
};

#endif // ABSTRACT_BOARD_H
